
// Dark GDK - The Game Creators - www.thegamecreators.com

// the wizard has created a very simple 3D project that uses Dark GDK
// it can be used as a starting point in making your own 3D games

// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
#include "GLWorld.h"

IGDKObjIDGen* g_pGDKIDGenerator = NULL;

// the main entry point for the application is this function
void DarkGDK ( void )
{
	// in this application we are going to create some 3D objects
	// and position them on screen

	// when starting a Dark GDK program it is useful to set global
	// application properties, we begin by turning the sync rate on,
	// this means we control when the screen is updated, we also set
	// the maximum rate to 60 which means the maximum frame rate will
	// be set at 60 frames per second
	dbSyncOn   ( );
	dbSyncRate ( 30 );

	GLWorld glWorld;
	g_pGDKIDGenerator = &glWorld;
	glWorld.InitWorldObjs();

	// move our camera back so we can view the objects
	dbPositionCamera ( 0, -100, -56 );
	dbXRotateCamera ( -69 );
	//	dbSetCameraFOV (0.5);

	// turn backdrop off
	dbBackdropOff ( );

	// switch light normalization on
	dbSetNormalizationOn ( );

	//for ( int i = 1; i < 8; i++ )
	//{
	//	dbMakeLight     ( i );
	//	dbSetPointLight ( i, 0, 0, 0 );
	//	dbSetLightRange ( i, 2000 );

	//	dbMakeObjectSphere ( 2 + i, 50 );
	//	dbGhostObjectOn    ( 2 + i );

	//	if ( i > 1 )
	//	{
	//		dbHideLight  ( i );
	//		dbHideObject ( 2 + i );
	//	}
	//}

	float ax = dbCameraAngleX ();
	float ay = dbCameraAngleY ();
	float az = dbCameraAngleZ ();
	int nTextX =0;
	int nSpeed=2;



	while ( LoopGDK ( ) )
	{
		// display some text on screen
		dbText ( nTextX, 0, "Hello GDK." );
		nTextX+=nSpeed;
		if ( nTextX>100 || nTextX<=0 )
			nSpeed *= -1;

		// 		// move the camera forwards
		// 		if ( dbUpKey ( ) )
		// 			dbMoveCamera ( 1 );
		// 
		// 		// move the camera backwards
		// 		if ( dbDownKey ( ) )
		// 			dbMoveCamera ( -1 );
		// colour lights
		//float leva  = 0.0f;
		//leva  = dbWrapValue ( leva + 0.01f );
		//float level = ( float ) cos ( leva );
		//int i;
		//for ( i = 1; i < 8; i++ )
		//{
		//	float col = 127.0f + ( 127.0f * level );
		//	float rev = col *- 1;

		//	if ( i == 1 ) dbColorLight ( i, ( int ) col, ( int ) rev, ( int ) rev );
		//	if ( i == 2 ) dbColorLight ( i, 128, ( int ) col, 128 );
		//	if ( i == 3 ) dbColorLight ( i, 255, 255, ( int ) col * 2 );
		//	if ( i == 4 ) dbColorLight ( i, ( int ) col, ( int ) rev, ( int ) col );
		//	if ( i == 5 ) dbColorLight ( i, ( int ) col, ( int ) col, ( int ) col );
		//	if ( i == 6 ) dbColorLight ( i, 500, 500, 500 );
		//	if ( i == 7 ) dbColorLight ( i, ( int ) rev * 3,( int ) rev * 3, ( int ) rev * 3 );
		//}
		//int keypress = 0;
		//char* szKey = dbInKey ( );

		//if ( strspn ( szKey, "1234567" ) )
		//{
		//	if ( keypress == 0 )
		//	{
		//		keypress = 1;

		//		int i = 1 + ( dbAsc ( szKey ) - dbAsc ( "1" ) );

		//		if ( dbLightVisible ( i ) )
		//		{
		//			dbHideLight  ( i );
		//			dbHideObject ( i + 2 );
		//		}
		//		else
		//		{
		//			dbShowLight  ( i );
		//			dbShowObject ( i + 2 );
		//		}
		//	}
		//}
		//else
		//	keypress = 0;

		glWorld.RunAFrame();

		dbSync ( );
	}

	// and now everything is ready to return back to Windows
	return;
}

